#pragma once
#include "Packet.h"
#include "CmdClient.h"

class CmdHandler
{
private:
	CmdHandler();
	virtual ~CmdHandler();
public:
	static CmdHandler* Instance();
	void Handle(CmdClient* client, Packet* pPacket);
	void GeneralResp(UvClient* client, unsigned char cmd, unsigned char result);
	void SpecialResp(UvClient* client, unsigned char cmd, unsigned char* pData, int length);
private:
	void GetVersion(UvClient* client, Packet* pPacket);
	void OnGetAcc(UvClient* client, Packet* pPacket);
	void OnPowerCtrl(UvClient* client, Packet* pPacket);
	void OnGetPowerVoltage(UvClient* client, Packet* pPacket);
	void OnCanCount(UvClient* client, Packet* pPacket);
	void OnCanWrite(UvClient* client, Packet* pPacket);
	void OnCanBaudrateGet(UvClient* client, Packet* pPacket);
	void OnCanBaudrateSet(UvClient* client, Packet* pPacket);
	void OnCanFilterCtrl(UvClient* client, Packet* pPacket);
	void OnCanHwFilterAdd(UvClient* client, Packet* pPacket);
	void OnCanHwFilterClear(UvClient* client, Packet* pPacket);
	void OnCanSwFilterAdd(UvClient* client, Packet* pPacket);
	void OnCanSwFilterClear(UvClient* client, Packet* pPacket);
	void OnBlockGetCount(UvClient* client, Packet* pPacket);
	void OnBlockWrite(UvClient* client, Packet* pPacket);
	void OnBlockRead(UvClient* client, Packet* pPacket);
	void OnInputGetCount(UvClient* client, Packet* pPacket);
	void OnInputGet(UvClient* client, Packet* pPacket);
	void OnOutputGetCount(UvClient* client, Packet* pPacket);
	void OnOutputGet(UvClient* client, Packet* pPacket);
	void OnOutputSet(UvClient* client, Packet* pPacket);
	void UpdateMcu(UvClient* client, Packet* pPacket);

	void OnCallbackSet(CmdClient* client, Packet* pPacket);
private:
	static CmdHandler* m_pInstance;
};
